
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品审核</title>
    <script src="/jquery/jquery-3.2.1.min.js"></script>
    <script src="/layui/layui.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/examine/productExamine/product-audit.css">
    <style>
    </style>
</head>
<body>
<div id="app" class="box">
    <form class="layui-form" lay-filter="audit">
        <p id="productName"></p>
        <input name="courseId" id="courseId" type="hidden" />
        <input name="implementId" id="implementId" type="hidden" />
        <input name="type" id="type" type="hidden" />
        <input name="details" id="details" type="hidden" value="3"/>
        <input name="auditTime" id="auditTime" type="hidden" />
        <p id="check">
            商品审核：
            <input name="result" type="radio" checked lay-filter="check" title="审核通过" value="1"/>
            <input name="result" type="radio" lay-filter="check" title="审核不通过" value="3" />
        </p>
        <p>
            反馈详情：
        <div class="layui-form-text">
            <div class="layui-input-block" >
                <textarea name="remarks" placeholder="请输入内容" lay-verify="content"  id="demo_editor" class="layui-textarea" ></textarea>
            </div>
        </div>
        </p>
        <div class="buttonBox">
            <button class="layui-btn layui-btn-normal" type="submit" id="confirm" lay-filter="confirm" lay-submit >确定</button>
            <button class="layui-btn layui-btn-primary" id="cancel" type="button">关闭</button>
        </div>
    </form>
</div>
</body>
<script>
    layui.use(['jquery','layer','form'],function(){
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;

        //关闭按钮点击事件
        $('#cancel').click(function () {
            var layer = parent.layer;
            layer.close(layer.index);
        });

        $('#confirm').click(function () {
            $('#auditTime').val(setTime());
        });


        form.on('submit(confirm)',function (data) {
            var dataField = data.field;
            $.ajax({
                url: '/SyCourseRecord/updatedetails',
                data: data.field,
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    var layer = parent.layer;
                    layer.close(layer.index);

                    var user = JSON.parse(localStorage.getItem("user"));
                    var param = {
                        "examineType":5,
                        "type":dataField.result,
                        "userId":user.data.userId,
                        "userName":user.data.trueName,
                        "createDate":setTime(),
                        "remark":dataField.remark,
                        "examineId":dataField.courseId
                    };
                    $.ajax({
                        url:"/JsAuditLog/addJsAuditLog",
                        data:param,
                        type:'post',
                        dataType:'json',
                        success:function (data) {
                            if(data.data == true){
                                layer.msg("审核通过");
                            }

                        }
                    });
                }
            });

            return false;
        });
        //获取 年月日 时分秒 星期
        function setTime(){
            var date = new Date();
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var today = date.getDate();
            var hour = date.getHours();
            var minute = date.getMinutes();
            var second = date.getSeconds();
            //当小时小于10时进行补零
            var currentTime = zeroFill(year) + '-' + zeroFill(month) + '-' + zeroFill(today) +  ' ' + zeroFill(hour) + ':' + zeroFill(minute) + ':' + zeroFill(second);
            return currentTime;
        }
        //补零
        function zeroFill(time){
            if(time < 10){
                time = '0' + time;
            }
            return time;
        }
    })
</script>
</html>